home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / gnustuff / tos / othergnu / flip.zoo / flip.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-06  |  7.6 KB  |  213 lines

  1. /* ::[[ @(#) flip.h 1.16 89/07/04 17:00:46 ]]:: */
  2.  
  3. /*
  4. Copyright 1989 Rahul Dhesi, All rights reserved.
  5.  
  6. Checksum: 2652839101 (check or update with "brik")
  7.  
  8. ANSI-compatibility strategy:
  9.  
  10. 1.   If ANSIPROTO is defined, function prototypes are used, ANSI-style.
  11.      If it is not defined, regular function declarations (without a
  12.      parameter list) are used.  This is achieved with the use of
  13.      the PARMS macro.
  14. 2.   If STDINCLUDE is defined, ANSI-conformant header files are
  15.      included.  Otherwise functions that would be declared in such
  16.      header files are declared individually.
  17. */
  18.  
  19. #ifndef OK_NL
  20.  
  21. /* Define ANSIPROTO and/or STDINCLUDE here if needed */
  22.             
  23. # define    ANSIPROTO
  24. # define    STDINCLUDE
  25.  
  26. #ifdef TURBOC
  27. # define    ANSIPROTO
  28. # define    STDINCLUDE
  29. #endif /* TURBOC */
  30.  
  31.  
  32.  
  33. #include <stdio.h>
  34.  
  35. #ifndef PARMS
  36. # ifdef ANSIPROTO
  37. #  define   PARMS(x)    x
  38. # else
  39. #  define   PARMS(x)    ()
  40. # endif
  41. #endif
  42.  
  43. /************************************************************/
  44. /*** change following definitions as needed for your system */
  45. /************************************************************/
  46. /*
  47. BIGBUF      If defined, setvbuf() will be used to set input and
  48.             output buffers to BIGBUF characters
  49. BINCHAR     This must be a macro accepting a single character
  50.             argument and returning nonzero if and only if that
  51.             character is a binary character.  By default, BINCHAR
  52.             is defined to look up a table, and the table is compiled
  53.             in by defining USE_TABLE.
  54. CHECK_BREAK If your operating system requires programs to check
  55.             for user interrupts at intervals, define CHECK_BREAK to
  56.             be a function or macro that checks for a user interrupt.
  57.             Flip will call this at intervals.  If not needed,
  58.             define CHECK_BREAK to be null.
  59. DELFILE     Must be a function or macro that will accept one filenames
  60.             and delete that file, returning zero on success, nonzero
  61.             on failure.
  62. GETFT       Must be a macro with usage GETFT(file,name,var) that will
  63.             take an open file, a filename, and a variable name, and
  64.             put in that variable the timestamp of the file.
  65. INT_EXIT    If USE_SIG is defined, INT_EXIT must be defined to
  66.             be the exit code returned by flip when its execution
  67.             is aborted by a user interrupt.
  68. MVFILE      Must be a function or macro that will take two filenames
  69.             and rename the first file to the second file, returning
  70.             zero on success, nonzero on failure.
  71. NIX         If this symbol is defined, some things common to most
  72.             implementations of **IX get defined and need not be
  73.             individually defined.
  74. PATHSIZE    size of buffer(s) to use to hold pathname(s)
  75. PICKNAME    Do "#define PICKNAME" if you want the program to know its
  76.             name and respond to it.  If PICKNAME is not defined, the
  77.             program will assume that it is called "flip".
  78. SETFT       Must be a function or macro with usage SETFT(file,name,var)
  79.             that will take an open file, a filename, and a variable
  80.             name, and set the timestamp of the file from the variable.
  81. SIG_T       If USE_SIG is defined, then SIG_T must be defined
  82.             (or typedef'd) to be the data type returned by
  83.             (*signal).  Usually int or void.
  84. SPEC_EXIT   Like SPEC_INIT, but is called just before flip exits.
  85. SPEC_INIT   This is invoked to initialize flip.  Should be defined to
  86.             be either a function call (with trailing semicolon) or
  87.             null string.
  88. SGFTIME     This must be a typedef for a data type suitable to store
  89.             file times.
  90. USE_TABLE   If this is defined, flip code will use a table look-up
  91.             to decide which characters should be considered binary.
  92.             See also BINCHAR.
  93. ULTRIX_BUG  At least one version of Ultrix chokes on a trailing "b"
  94.             in the mode string for fopen().  If ULTRIX_BUG is defined
  95.             no trailing "b" will be used.
  96. USE_SIG     If this is defined, then signal() will be used so flip
  97.             may trap user interrupts and delete temporary files.
  98.             If USE_SIG is defined, then SIG_T and INT_EXIT must also
  99.             be defined (below).
  100. WILDCARD    If this is defined, the function nextfile() will be called
  101.             to expand wildcards.  If WILDCARD is not defined, no
  102.             wildcard expansion will be done and nextfile() is not
  103.             needed.  For a description of nextfile() see turboc.c.
  104. */
  105.  
  106. #ifdef TURBOC
  107. # define PATHSIZE    200
  108. # define PICKNAME
  109. # define BIGBUF      16384
  110. # define DELFILE     remove
  111. extern int MVFILE PARMS ((char *src, char *dest));            /* Turbo C */
  112. # define USE_SIG
  113. # define SIG_T void     /* return type from (*signal) */
  114. # define INT_EXIT 127   /* status when a signal causes exit */
  115. # define CHECK_BREAK  brktst();
  116. void brktst PARMS ((void));
  117. # define SPEC_INIT   spec_init();
  118. # define SPEC_EXIT   spec_exit();
  119. void spec_init PARMS ((void));
  120. void spec_exit PARMS ((void));
  121. # define WILDCARD
  122.  
  123. /* date and time */
  124. # include <io.h>
  125.   typedef struct ftime        SGFTIME;
  126. # define GETFT(f,name,var)    getftime(fileno(f), &var)
  127. # define SETFT(f,name,var)    setftime(fileno(f), &var)
  128. #endif /* TURBOC */
  129.  
  130. #ifdef SYS_V */
  131. # define NIX         /* see below */
  132. # define PATHSIZE    200
  133. # define BIGBUF      16384
  134. # define  MVFILE(src,dest)    (!(!link(src,dest)&&!unlink(src)))
  135. # define SIG_T int
  136. #endif /* SYS_V */
  137.  
  138. #ifdef BSD
  139. # define NIX         /* see below */
  140. # define PATHSIZE    1027
  141. # undef  BIGBUF
  142. # define  MVFILE     rename
  143. # define SIG_T int
  144. #endif /* BSD */
  145.  
  146. #ifdef VMS
  147. # define PATHSIZE    1024
  148. # define PICKNAME
  149. # define BIGBUF      16384
  150. # define DELFILE     delete
  151. # define  MVFILE     rename
  152. # define USE_SIG
  153. # define SIG_T int
  154. # define INT_EXIT    127
  155. # define SPEC_INIT
  156. # define SPEC_EXIT
  157. #endif /* VMS */
  158.  
  159. /************************************************************/
  160. /*** remaining definitions should not need to be changed ****/
  161. /************************************************************/
  162.  
  163. /* define ASCII character values for linefeed, carriage return, control Z */
  164. #define  LF    10
  165. #define  CR    13
  166. #define  CTRLZ 26
  167.  
  168. /* error codes */
  169. #define  ERRBINF  1  /* binary file */
  170. #define  ERRSIG   2  /* interrupted by signal */
  171.  
  172. /* how to strip high bit */
  173. #define  STRIP(c)    c &= 0x7f
  174.  
  175. /**** BINCHAR(c) returns nonzero if c is a binary char ****/
  176. #ifndef BINCHAR
  177. # define USE_TABLE      /* use internal table -- see flip.c */
  178. # define BINCHAR(c)  bintab[c]
  179. #endif
  180.  
  181. /**** mode strings for fopen() -- to work around Ultrix problem ****/
  182. /**** (Thanks to Taso N. Devetzis for reporting this)           ****/
  183. #ifdef ULTRIX_BUG
  184. # define WB          "w"
  185. # define RB          "r"
  186. # define R_PL_B      "r+"
  187. #else
  188. # define WB          "wb"     /* write binary */
  189. # define RB          "rb"     /* read binary */
  190. # define R_PL_B      "r+b"    /* read + update binary */
  191. #endif /* ULTRIX_BUG */
  192.  
  193. /* things common to most **IX systems */
  194. #ifdef NIX
  195. # define SPEC_INIT
  196. # define SPEC_EXIT
  197. # define CHECK_BREAK
  198. # define PICKNAME
  199. # define DELFILE     unlink
  200. # define USE_SIG
  201. # define INT_EXIT    127
  202. # include <sys/types.h>          /* for file time */
  203. # include <sys/stat.h>           /* for file time */
  204.   typedef struct stat            SGFTIME;
  205. # define GETFT(file,name,var)    fstat(fileno(file),&var)
  206. # define SETFT(file,name,var)    do { time_t x[2]; x[0] = var.st_atime; \
  207.                                       x[1] = var.st_mtime; utime (name, x); \
  208.                                   } while (0)
  209. #endif /* NIX */
  210.  
  211. #endif /* OK_NL */
  212.  
  213.